﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CheckAvailableRoomCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var world:WorldModel;
		[Inject]
        public var roomSlots:RoomSlotsModel;

        override public function execute():void{
            var _local1:ITreatable = ITreatable(this.event.info);
            var _local2:Array = this.roomSlots.getNearestFreeRoom(_local1.roomId, _local1.currentTreatment.roomType, this.world.building, _local1.id);
            if (_local2){
                _local1.moveToNextTreatment();
            } else {
                dispatch(new InfoEvent(EventConstants.ADD_TO_QUEUE, null, _local1));
            };
        }

    }
}//package net.wooga.pets.views 
